package cqgans.app.sunao.com.cqgans.ui;

import android.app.Activity;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import cqgans.app.sunao.com.cqgans.common.AppConstant;
import cqgans.app.sunao.com.cqgansnew.R;

/**
 * Created by sunao on 2017/6/12.
 */

public class BaseActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public Resources getResources() {
        Resources res = super.getResources();
        Configuration config=new Configuration();
        config.setToDefaults();
        res.updateConfiguration(config,res.getDisplayMetrics() );
        return res;
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
    public void setTitleBar(String title,int type){
        switch (type){
            case 1://纯title
                this.findViewById(R.id.back).setVisibility(View.GONE);
                this.findViewById(R.id.close).setVisibility(View.GONE);
                this.findViewById(R.id.user_ll).setVisibility(View.GONE);
                break;
            case 2://返回关闭按钮
                this.findViewById(R.id.user_ll).setVisibility(View.GONE);

                break;
            case 3://用户
                this.findViewById(R.id.back).setVisibility(View.GONE);
                this.findViewById(R.id.close).setVisibility(View.GONE);
                ((TextView)findViewById(R.id.username)).setText(AppConstant.user.getUsername());

                break;
            case 4://全显示
            case 5://返回按钮
                this.findViewById(R.id.close).setVisibility(View.GONE);
                ((TextView)findViewById(R.id.username)).setText(AppConstant.user.getUsername());

                break;
            case 6://注册页面
                this.findViewById(R.id.close).setVisibility(View.GONE);
                this.findViewById(R.id.user_ll).setVisibility(View.GONE);

                break;

        }
        ((TextView)findViewById(R.id.title)).setText(title);

    }
    protected void settitleString(String s){
        ((TextView)findViewById(R.id.title)).setText(s);

    }
}
